#include <stdio.h>
#include <math.h>
#include <assert.h>


#ifndef NDEBUG
#define DOUT( toprint ) printf( "\n# " toprint )
#define DPUT( toput , x ) printf( "\n# " toput , x )
#define DLN
#else
#define DOUT
#define DPUT
#define DLN if(0)
#endif

int main()
{
	DOUT("=======================2007, 1 semester assignment, 1-A=======================");
	DOUT("==============================================================================");
	DOUT("Please enter the number of the numbers to be submitted to inspection:");
	DOUT(">");

	long long int n = 0;    //n is long long because that'll lead to more reliable asserts
	int chk = scanf("%lld", &n);
	DLN assert(("You have entered a single number" , chk == 1));
	DLN assert(("N is actually less than 10000" , (n < 10000)));

	DPUT("Enter those %lld numbers in question:", n);
	DOUT(">");

	long int nInput[10000] = {0},
	                         maxelem = 1;

	for(int i = 0; i < n; i++) {
		chk = scanf("%ld", &nInput[i]);				//idk why, but it doesn't properly check
		DLN assert(("No garbage input", chk == 1));	//if there were precisely n numbers
													 //in input. However, it rejects letters
		if(nInput[i] > maxelem)
			maxelem = nInput[i];
	}

	bool bComp[100000] = {0};			//if i-th of this is 1 then the i is composite

	for(long int j = 2; j < maxelem; j++) {

		if((!bComp[j]) && (j < (maxelem / 2))) {
			for(int k = 2*j; k <= maxelem; k += j)
				bComp[k] = 1;
		}

	}

	for(int i = 0; i < n; i++) {
		if(!(bComp[ nInput[i] ]))
			printf("%ld ", nInput[i]);
	}


	DOUT("==============================================================================");
	DPUT("FILE: %s", __FILE__);
	DPUT("TIME OF COMPILATION: %s", __TIME__);

	return 0;
}

